
function getCategory(id){
	$.ajax({
		type: "get",
	   	url: "get_category.htm",
	   	cache: false,
	  	data: {id:id},
	   	success: function(msg){
	   		$("#msg_cate_id").val(id);
	   		$(msg).find("content").each(function(i){
				var data = $(this); 
				$("#msg_cate").html(data.find("cate").text());
				if(data.find("isServ").text()==1){
					$("#isServ").attr("checked",true);
				}else{
					$("#isServ").attr("checked",false);
				}
				var value = data.find("distType").text();
				$("#distType option[value="+value+"]").attr("selected","selected");
				$("[name='stypeId']").attr("checked",false);
				$("[name='stypeId']").each(function(){
					var strs= new Array();
					var types = data.find("stypeId").text(); 
					strs=types.split(";"); 
					for(i=0;i<strs.length ;i++ ) { 
						if(strs[i]==$(this).val()){
							$(this).attr("checked",true);
						}   
   					 }			
				});
				
			});
	   		
	   	}
	});
}
function addCategory(){
	var categId = $("#msg_cate_id").val();
	if(categId==0){
		alert("请选择品类");
		return;
	}
	var isServ = 0;
	if($("#isServ").attr("checked")){
		isServ = 1;
	}
	var distType = $("#distType").val();
	var stypeId = "";
	$("[name='stypeId']").each(function(){
		if($(this).attr("checked")){
			stypeId += $(this).val()+";";
		}   
	});
	$.ajax({
		type: "post",
	   	url: "add_service.htm",
	   	cache: false,
	  	data: {categId:categId,isServ:isServ,distType:distType,stypeId:stypeId},
	   	success: function(msg){
	   		if(msg=="success"){
	   			alert("保存成功");
	   		}else if(msg=="noCateg"){
	   			alert("请选择品类");
	   		}else{
	   			alert("保存失败");
	   		}
	   	}
	});
}